<!--
**********************************************************
* @Author: 张小平
* @Date:   2024-05-01
* @Email:  qqshuqian@163.com
* @Last modified: 最后修改日期
* @Description: 文件描述
**********************************************************
-->
<template>
  <div>
    <el-input disabled prefix-icon="el-icon-location" v-model="address" />
  </div>
</template>

<script>
export default {
  name:"position",
  inject: ['viewFormData'],
  props: ['column', 'value'],
  mounted() {
    // console.log(this.column, this.value);
  },
  computed: {
    address() {
      const { addressType } = this.column
      return this.formateAddress(addressType, this.value)
    }
  },
  methods: {
    formateAddress(type, obj) {
      const { province, city, district, road, address } = obj || {}

      switch (type) {
        case 'province':
          return province || ''
        case 'city':
          return city ? `${province}${city}` : ''
        case 'district':
          return district ? `${province}${city}${district}` : ''
        case 'road':
          return road ? `${province}${city}${district}${road}` : ''
        default:
          return address || ''
      }
    }
  }
}
</script>
